<template>
  	<footer>
		<p>Copyright © 2019 <a href="http://www.lzdncloud.top" target="_blank">张林个人博客</a></p>

		<a href="#" class="cd-top">Top</a>
	</footer>
		
</template>
<script>
export default {
	name:'MyFooter',
	template:'<MyFooter/>',
	mounted(){
		this.initFooter();
	},
	methods:{
		initFooter:function(){
			//scroll to top
			var offset = 300,
				offset_opacity = 1200,
				scroll_top_duration = 700,
				$back_to_top = $('.cd-top');
		
			$(window).scroll(function () {
				($(this).scrollTop() > offset) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
				if ($(this).scrollTop() > offset_opacity) {
					$back_to_top.addClass('cd-fade-out');
				}
			});
			$back_to_top.on('click', function (event) {
				event.preventDefault();
				$('body,html').animate({
						scrollTop: 0,
					}, scroll_top_duration
				);
			});
		}
	}
}
</script>
